package com.example.mapper.comment;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.domain.comment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Controller;

import java.util.List;
import java.util.Map;

@Mapper
public interface commentQuery extends BaseMapper<comment> {

    @Update("Update user_lease set user_openid='0' where articlesid=${articlesid} and user_openid=${openid}")
    boolean genxin(int articlesid,String openid);

    @Select("select user_comments.id as id,user_comments.time as time,`user`.imgurl as img,user_comments.comments as comments,user_comments.commentuserid as commentuserid,user_comments.articlesid as articlesid FROM `user`,user_comments WHERE user_comments.articlesid=${id} and user.openid=user_comments.commentuserid")
    List<comment> select11(int id);

    @Select("SELECT user_comments.id as id,user_comments.comments as comments,user_comments.time as time,`user`.`name` as commentuserid FROM user_comments,`user` WHERE user_comments.commentuserid=`user`.openid AND `user`.`name` LIKE ${name} LIMIT ${a},${b}")
    List<comment> selectall(int a,int b,String name);

    @Select("select COUNT(*) FROM user_comments")
    int num();
}
